package fr.fermeManager.application.views;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;

import net.miginfocom.swing.MigLayout;

import com.jgoodies.forms.factories.DefaultComponentFactory;

import fr.fermeManager.application.controllers.BaseController;
import fr.fermeManager.application.controllers.ControllerUserSelection;

public class ViewUserSelection extends BasePanel {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JButton btnUser;
	private JButton btnAdmin;
	private JLabel label;
	

	/**
	 * Create the panel.
	 */
	public ViewUserSelection(BaseController baseControllerParam) {
		
		super(baseControllerParam);
		setFont(new Font("Tahoma", Font.PLAIN, 11));
		setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "S\u00E9lection utilisateur", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		setLayout(new MigLayout("", "[grow][center][grow]", "[grow][][grow]"));
		
		label = DefaultComponentFactory.getInstance().createLabel("");
		add(label, "cell 1 0");
		label.setIcon(new ImageIcon(ViewUserSelection.class.getResource("/img48x48/user.png")));
		
		JPanel panel = new JPanel();
		add(panel, "cell 1 1,grow");
		panel.setLayout(new MigLayout("", "[grow][][][grow]", "[grow][][grow]"));
		
				btnUser = new JButton("User");
				panel.add(btnUser, "cell 1 1");
				
				btnAdmin = new JButton("Admin");
				panel.add(btnAdmin, "cell 2 1");
				btnAdmin.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						((ControllerUserSelection) getBaseController()).selectionnerUtilisateur(e.getActionCommand());
					}
				});
				btnUser.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						((ControllerUserSelection)getBaseController()).selectionnerUtilisateur(e.getActionCommand());
					}
				});
		
	}
}
